/*******************************************************************************
 * Copyright (c) 2008 Sylvain Sicard.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Sylvain Sicard - initial API and implementation
 ******************************************************************************/
/*
 * Created on 24 oct. 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package fr.jade.console.cmd;

import java.util.LinkedList;

import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.util.Fractal;

import fr.jade.console.core.AbstractCommand;
import fr.jade.console.core.Command;
import fr.jade.console.core.Environment;

/**
 * @author Sylvain Sicard
 */
public class Pwd extends AbstractCommand implements Command{

  public String getDescription(){
    return "prints current path in the architecture";
  }
  
  public String getHelp() {
    return "pwd";
  }
  
  public String getName() {
    return "pwd";
  }
  
	@SuppressWarnings("unchecked")
  public Object execute(String[] args, Environment env) throws Throwable {
		
		LinkedList<Component> pwd = (LinkedList<Component>)env.getEnvVar("pwd");
		
		for ( int i=0; i<pwd.size(); i++ ){
			System.out.print(Fractal.getNameController(pwd.get(i)).getFcName()+"/");
		}
		System.out.println();
		return null;
	}
}
